import Vue from 'vue'
import App from './App'
import store from './vuex'
import VueRouter from 'vue-router'
import VueResource from 'vue-resource'
import axios from 'axios'
import MintUI from 'mint-ui';
import 'mint-ui/lib/style.css';
import echarts from 'echarts'


import login from './views/login.vue'
import index from './views/index.vue'
import order from './views/order.vue'
import goods from './views/goods.vue'
import personinfo from './views/personinfo.vue'
import test from './views/test.vue'
import stores from './vuex/index.js'

Vue.prototype.$echarts = echarts 
Vue.prototype.$http = axios;  

//注册VueRouter这个插件
Vue.use(VueRouter)
//注册MintUi
Vue.use(MintUI)
//注册Vue-resource
Vue.use(VueResource)

// axios.interceptors.request.use(function(config){  
//     stores.dispatch('showloader')  
//     return config  
// },function(err){  
//     return Promise.reject(err)  
// });  
// axios.interceptors.response.use(function(response){  
//     stores.dispatch('hideloader')  
//     return response  
// },function(err){  
//     return Promise.reject(err)  
// });  

const routes = [
    { path: '/login', component: login },
    { path: '/index', component: index },
    { path: '/order', component: order },
    { path: '/goods', component: goods },
    { path: '/personinfo', component: personinfo },
    { path: '/test', component: test },
    { path: '*', redirect:'/login'}
]
const router = new VueRouter({
    routes // （缩写）相当于 routes: routes
})

new Vue({
  el: '#app',
  store,
  render: h => h(App),
  router
})
